package com.survivor.launcher;

import com.survivor.model.AppMgr;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class ContentView extends SurfaceView implements SurfaceHolder.Callback{

	
	private SurfaceHolder holder;
	
	private Canvas canvas = null;
	
	private Bitmap testBmp;
	
	
	public ContentView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		holder = this.getHolder();
		holder.addCallback(this);
		
		testBmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
		
		AppMgr.getInstance().initAppList(context);
	}
	
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		// TODO Auto-generated method stub
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub
		canvas = holder.lockCanvas();
		onMyDraw(canvas);
		holder.unlockCanvasAndPost(canvas);
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		
	}
	
	
	public void onMyDraw(Canvas canvas)
	{
		canvas.drawBitmap(testBmp, 0, 0, null);
	}
	
	

}
